import * as filters from '@/common/filters' // global filters
// 导出的是对象，可以直接通过 key 和 value 来获得指令名和指令对象属性。
import * as directives from '@/directives'

import Toast from '@/plugins/toast'
import Loading from '@/plugins/loading'
import Alert from '@/plugins/alert'

import LoadMore from '@/components/common/CommonLoadMore'
import CommonHeader from '@/components/common/CommonHeader'
import Container from '@/components/common/CommonContainer'

import globalEnvironmentMixin from '@/mixins/globalEnvironmentMixin'
import { $session } from '@/utils'

// 引入app交互js桥文件。
import vpBridge from '@/utils/webViewBridgeClass'
import request from "../api/api";


function install (Vue, options) {
  // register global utility filters
  Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
  })
  // 通过Object.keys遍历以注册所有的自定义指令。
  Object.keys(directives).forEach(key => {
    Vue.directive(key, directives[key])
  })

  Vue.prototype.$session = $session
  Vue.prototype.$request = request

  Vue.component('LoadMore', LoadMore) // 提示弹窗
  Vue.component('CommonHeader', CommonHeader) // 头部组件
  Vue.component('Container', Container) // 页面布局

  Vue.use(Toast)
  Vue.use(Alert)
  Vue.use(Loading)

  Vue.mixin(globalEnvironmentMixin)
}
export default install
